package com.pzhu.user.domain.dto.converter;

import com.pzhu.user.api.PermissionApi;
import com.pzhu.user.domain.ro.PermissionCreateRO;
import com.pzhu.user.domain.ro.PermissionUpdateRO;
import com.pzhu.user.domain.vo.PermissionSearchVO;
import org.mapstruct.*;

@Mapper(
        componentModel = MappingConstants.ComponentModel.SPRING,
        nullValueCheckStrategy = NullValueCheckStrategy.ALWAYS,
        unmappedTargetPolicy = ReportingPolicy.IGNORE,
        collectionMappingStrategy = CollectionMappingStrategy.ADDER_PREFERRED)
public interface PermissionDtoConverter {

    PermissionCreateRO convert(PermissionApi.PermissionCreateDTO permissionDTO);

    PermissionUpdateRO convertUpdate(PermissionApi.PermissionUpdateDTO permissionUpdateDTO);

    @Mapping(target = "permissionId", source = "id")
    @Mapping(target = "permissionCode", source = "code")
    @Mapping(target = "description", source = "desc")
    @Mapping(target = "createTime", source = "createTime")
    @Mapping(target = "updateTime", source = "updateTime")
    PermissionApi.PermissionDTO toDTO(PermissionSearchVO permissionSearchVO);
}